﻿using DongFangGuoKai.WMSPlatform.Domain.Enums;
using DongFangGuoKai.WMSPlatform.Domain.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace DongFangGuoKai.WMSPlatform.Service.LogApp
{
    public partial class LogService
    {
        public TInterfaceLog AddInterfaceLog(TInterfaceLog log)
        {
            return InterfaceLogRepo.Insert(log);
        }

        public bool UpdateInterfaceLog(TInterfaceLog log)
        {
            return InterfaceLogRepo.Update(log);
        }

        public List<TInterfaceLog> GetInterfaceLogList(int pageIndex, int pageSize, EmInterfaceLogType? type, int? status, string? keyWords)
        {
            var queryble = InterfaceLogRepo.GetQueryable();
            if (type != null)
            {
                queryble = queryble.Where(x => x.LogType == type);
            }
            if (status != null)
            {
                queryble = queryble.Where(x => x.Status == status);
            }
            if (!string.IsNullOrEmpty(keyWords))
            {
                queryble = queryble.Where(x => x.Name == keyWords);
            }
            return queryble
                .Skip((pageIndex - 1) * pageSize)
                .Take(pageSize)
                .OrderByDescending(x => x.Id)
                .ToList();




        }
    }
}
